#include "IndexBuffer.h"
#include "GraphicsDeviceManager.h"

IndexBuffer::IndexBuffer()
{
	glGenBuffersARB(1, &m_nID);
}

IndexBuffer::~IndexBuffer()
{
	glDeleteBuffersARB(1, &m_nID);
}

void IndexBuffer::SetData(void* data, unsigned int sizeInBytes, BufferUsage bufferUsage)
{
	m_nSizeInBytes = sizeInBytes;
	m_nElementCount = sizeInBytes / sizeof(unsigned int);

	glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_nID);
	glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, sizeInBytes, data, bufferUsage);
	glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
}

const unsigned int IndexBuffer::GetID() const
{
	return m_nID;
}

const unsigned int IndexBuffer::GetElementCount() const
{
	return m_nElementCount;
}

const unsigned int IndexBuffer::GetSizeInBytes() const
{
	return m_nSizeInBytes;
}